<script>
  var user_age;
  var user_year=prompt("Enter the year you were born:","");
  var user_month=prompt("Enter the month you were born:","");
  var user_day=prompt("Enter the day you were born:","");

  var birthday_date=new Date();
  birthday_date.setMonth(user_month-1);
  birthday_date.setDate(user_day);

  var current_date=new Date();
  var current_year=current_date.getYear();

  if(current_date < birthday_date)
    user_age=current_year - user_year-1;
  else
    user_age=current_year - user_year;

  alert("You are "+user_age+" years old.");
</script>
